#include "PrecompiledHeader.h"
#include "IniSection.h"

/*--------------------------------------------------------------------------*/

IniFileSection::IniFileSection(const std::string& name) :
	m_name(name)
{
}

/*--------------------------------------------------------------------------*/

IniFileSection::~IniFileSection()
{
	for (std::list<IniFileItem*>::iterator i = this->m_iniItemsList.begin(); i != this->m_iniItemsList.end(); ++i)
	{
		delete(*i);
	}
}

/*--------------------------------------------------------------------------*/

void IniFileSection::AddItem(const std::string& name, const std::string& value)
{
	this->m_iniItemsList.push_back(new IniFileItem(name, value));
}

/*--------------------------------------------------------------------------*/

const std::string& IniFileSection::GetName() const
{
	return this->m_name;
}

/*--------------------------------------------------------------------------*/

IniFileItem* IniFileSection::GetItem(const std::string& name) const
{
	for (std::list<IniFileItem*>::const_iterator I = this->m_iniItemsList.begin(); I != this->m_iniItemsList.end(); I++)
	{
		if ((*I)->GetName() == name)
		{
			return (*I);
		}
	}

	return NULL;
}

/*--------------------------------------------------------------------------*/
